Skip to content

docs correct the fromCode range description - #156

Closed
theluckystrike wants to merge 1 commit into
gren-lang:mainfrom
theluckystrike:ws/fromcode-doc-range-0920-0900
Closed

theluckystrike wants to merge 1 commit into
gren-lang:mainfrom
theluckystrike:ws/fromcode-doc-range-0920-0900

Conversation

@theluckystrike

Copy link
Copy Markdown

Fixes #149

The fromCode doc comment said numbers outside the unicode range return the replacement character. The kernel uses String.fromCodePoint, which throws a RangeError for those inputs. This updates the doc comment and drops the now wrong example.

@robinheghan

Copy link
Copy Markdown
Member

Hi!

Gren code should not throw exceptions, so changing the docs is not a way to fix this issue.

For backwards compatibility, we catch the exception and return the replacement character. We should also add a unit test to verify.

@theluckystrike

Copy link
Copy Markdown
Author

Thanks @robinheghan. I see this is fixed properly in 7be0d24 on release-7.5.0, with the try/catch returning Char.replacementChar and the docs kept as they were, so this docs change is no longer right. Closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Char.fromCode throws a RangeError out of range, but its documentation says it returns U+FFFD

2 participants